<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  const aa = /(?:fo)/g // 非捕获组
  const bb = /(fo)/g //捕获组
  const dd = "fofofofofofo"
  dd.replace(aa, function (a, offset,org) {
    console.log("~~~a,$1,$2~~~~", a, org, offset); //fo fofofofofofo 0
  })
  dd.replace(bb, function (a, $1,offset, org,) {
    console.log("~~~a,$1,$2~~~~", a, $1, org, offset); //fo fo fofofofofofo 0
  })

  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  var str = "Hahaha interesting";
  var reg = /(?:ha)+/g;
  var reg1 = /(?:ha)+ (\w+)/g;
  console.log("aa.test(dd)", dd.match(aa));
  console.log(str.match(reg)); // ["Hahaha"]
  console.log(str.match(reg1)) // ["Hahaha interesting", "interesting"]

</script>

</html>